package com.tomehay.termprojectmanage_server.pojo.Model;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.List;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tomehay.termprojectmanage_server.mapper.GroupMemberMapper;
import com.tomehay.termprojectmanage_server.mapper.StudentMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 
 * </p>
 *
 * @author tomehay
 * @since 2023-06-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class GroupMember {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private Integer studentId;

    private Integer isLeader;

    private Integer groupId;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    private LocalDateTime updateTime;


    public static String GetMembers(GroupMemberMapper groupMemberMapper , int group_id , StudentMapper studentMapper){
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("group_id",group_id);

        String res = new String();

        List<GroupMember> groupMembers = groupMemberMapper.selectList(queryWrapper);
        for (GroupMember groupMember : groupMembers) {
            res += Student.GetNoAndName(studentMapper, groupMember.getStudentId())+"、";
        }
        return res;
    }

    public static String GetMemberName(GroupMemberMapper groupMemberMapper , int id , StudentMapper studentMapper){


        GroupMember groupMember = groupMemberMapper.selectById(id);
        return Student.GetNoAndName(studentMapper, groupMember.getStudentId());

    }

}
